package vns.server.domain;


import java.util.Set;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Key;

import vns.shared.RoleDTO;

@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = "true")

public class Role {
    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Key id;
	@Persistent()
	private Set<Key> perm;
	@Persistent
	private String name;
	@Persistent
	private String describe;
	
	public Role(RoleDTO roleDTO){
		this.name=roleDTO.getName();
		this.describe=roleDTO.getDescribe();
	}
	
	public void updatefromDTO(RoleDTO roleDTO){
		this.name=roleDTO.getName();
		this.describe=roleDTO.getDescribe();
	}
	
	public RoleDTO toDTO(){
		RoleDTO roleDTO=new RoleDTO(this.id,this.name,this.describe);
		return roleDTO;
	}
	
	public Key getId(){
		return id;
	}
	
	public Set<Key> getPerm(){
		return perm;
	}
	
	public void addPerm(Key _perm){
		this.perm.add(_perm);
	}
	
	public void removePerm(Key _perm){
		this.perm.remove(_perm);
	}
	
	public String getName(){
		return name;
	}
	
	public void setName(String Name){
		this.name=Name;
	}
	
	public String getDescribe(){
		return describe;
	}
	
	public void setDescribe(String Describe){
		this.describe=Describe;
	}

}
